<?php

use yii\helpers\Html;
use yii\helpers\ArrayHelper;
use yii\widgets\ActiveForm;
use backend\models\Project;
use kartik\select2\Select2;
use Da\User\Model\User;
use backend\helpers\ActionButton;

/* @var $this yii\web\View */
/* @var $model backend\models\Project */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="create-form project-form">

    <?php $form = ActiveForm::begin(); ?>

    <?= $form->field($model, 'status')->dropdownList(
            Project::getStatusList(),
            [
                'prompt' => 'Выберете стутус проекта...'
            ])
    ?>

    <?= $form->field($model, 'title')->textInput(['maxlength' => true]) ?>
    <?= $form->field($model, 'description')->textarea(['rows' => 6, 'maxlength' => true]) ?>
    
    <br>
    
    <?= $form->field($model, 'id_accountant')->widget(Select2::classname(), [
            'data' => ArrayHelper::map(User::find()->with('profile')->all(), 'id', 'profile.name'),
            'options' => ['placeholder' => 'Выберите сотрудника...'],
        ]); 
    ?>

    <?= $form->field($model, 'id_curator')->widget(Select2::classname(), [
            'data' => ArrayHelper::map(User::find()->with('profile')->all(), 'id', 'profile.name'),
            'options' => ['placeholder' => 'Выберите сотрудника...'],
        ]); 
    ?>

    <div class="row">
        <?= $form->field($model, 'date_start', ['options' => ['class' => 'col-sm-3']])->input('date')  ?>
        <?= $form->field($model, 'date_realize', ['options' => ['class' => 'col-sm-3']])->input('date') ?>
    </div>

    <?= $form->field($model, 'url_work_budget')->textInput(['maxlength' => true]) ?>

    <?= $form->field($model, 'is_proxy')->radioList(
        [
            Project::PROXY => 'Да',
            Project::OWN => 'Нет, это наш проект',
        ])
    ?>

    <br>
    
    <div class="form-group">
        <?= Html::submitButton('Сохранить', ['class' => 'btn btn-success']) ?>
    </div>

    <?php ActiveForm::end(); ?>

</div>
